<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- css js-->
<script type="text/javascript">
	function showWin(wid, url) {
			$('#' + wid).window('open');
			$('#' + wid).window('refresh', url );
	}

	function doSearch() {
		$('#dg').datagrid('options').pageNumber = 1;//设置页码初始值为1
		$('#dg').datagrid({
			queryParams : $('#sform').serializeObject()
		});
	}

	function editJzdm(gid, wid, url) {
		var row = $('#' + gid).datagrid('getSelected');
		if (row != null) {
			$('#' + wid).window('open');
			$('#' + wid).window('refresh', url + '?id=' + row.dm);
		} else {
			$.messager.alert('警告', '请选择要修改的记录！');
		}
	}

	function deleteJzdm(gid, url) {
		var row = $('#' + gid).datagrid('getSelected');
		if (row != null) {
			$.messager.confirm('确认', "确认删除吗？", function(r) {
				if (r) {
					$.ajax({
						type : 'post',
						url : url,
						data : {
							'id' : row.dm
						},
						dataType : 'json',
						success : function(data) {
							if (data) {
								if (data.ack_code == "SUCCESS") {
									showMsg('提示', data.data);
									if (gid && gid != '') {
										$('#' + gid).datagrid({});
									}
								} else {
									showMsg('提示', data.data);
								}
							} else {
								showMsg('提示', '删除失败！');
							}
						}
					})
				}
			})
		} else {
			$.messager.alert('警告', '请选择要删除的记录！');
		}
	}

	function batchDelJzdm(gid, url) {
		var rows = $('#' + gid).datagrid('getSelections');
		var ids = "";
		for (var i = 0; i < rows.length; i++) {
			ids += rows[i].dm + ","
		}
		;
		ids = ids.substr(0, ids.length - 1);
		if (ids != '') {
			$.messager.confirm('确认', "确认删除吗？", function(r) {
				if (r) {
					$.ajax({
						type : 'post',
						url : url,
						data : {
							'ids' : ids
						},
						success : function(data) {
							if (data) {
								if (data.ack_code == "SUCCESS") {
									showMsg('提示', data.data);
									if (gid && gid != '') {
										$('#' + gid).datagrid({});
									}
								} else {
									showMsg('提示', data.data);
								}
							} else {
								showMsg('提示', '批量删除失败！');
							}
						}
					})
				}
			})
		} else {
			$.messager.alert('警告', '请选择要删除的记录！');
		}
	}
</script>
<title>街镇列表</title>
</head>
<body style="margin: 0; padding: 0">
	<div id="cc" class="easyui-layout" data-options="fit:true">
		<%--查询条件--%>
		<div id="tb" style="padding: 10px;">
			<form id="sform" method="post">
				<a href="#" class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="showWin('win','${ctx}/lsj/building/conditionSearch');">添加条件</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-add"
					plain="true" onclick="showWin('win','${ctx}/lsj/town/showModify');">新增</a>
				<a href="javascript:void(0);" class="easyui-linkbutton"
					iconCls="icon-edit" plain="true"
					onclick="editJzdm('dg','win','${ctx}/lsj/town/showModify');">修改</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-remove"
					plain="true" onclick="deleteJzdm('dg','${ctx}/lsj/town/delete')">删除</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-bdel"
					plain="true"
					onclick="batchDelJzdm('dg','${ctx}/lsj/town/batchDel')">批量删除</a>
			</form>
			<div id="win" class="easyui-window" title="街镇管理"
				data-options="iconCls:'${icon}',collapsible:false,minimizable:false,maximizable:false,closed:true"
				style="width: 600px; height: 350px; background-color: white;"></div>
		</div>
		<%--查询条件--%>
		<%--查询结果列表--%>
		<table class="easyui-datagrid" id="dg"
			style="width: 100%; height: 100%; padding: 0px;"
			data-options="
	                border:false,
	                rownumbers:true,
	                singleSelect:false,
	                autoRowHeight:false, 
	                pagination:true,
	                method:'POST',
	                toolbar:'#tb',
	                url:'${ctx}/lsj/building/search2',
	                pageSize:20">
			<thead>
				<tr>
					<th data-options="field:'ck',checkbox:true"></th>
					<th field="dm" hidden=true>dm</th>
					<th field="jz" width="10%" align="center">街镇</th>
					<th field="jwh" width="10%" align="center">居委会</th>
					<th field="czwxz" width="10%" align="center">出租屋性质</th>
					<th field="jddm" width="10%" align="center">街路巷</th>
					<th field="mpmc" width="10%" align="center">门牌名称</th>
					<th field="sfzx" width="10%" align="center">是否注销</th>
					<th field="sftycqr" width="10%" align="center">是否同一产权人</th>

				</tr>
			</thead>
		</table>
		<%--查询结果列表完--%>
	</div>
</body>
</html>
